from django.shortcuts import render

# Create your views here.
from users.models import User
from rest_framework.response import Response
from rest_framework.views import APIView


class RegisterUsernameCountView(APIView):

    """
    获取用户名的个数
    GET： /users/username/(?P<username>\w{5,20})/count/
    """""

    def get(self,request,username):

        # 通过模型查询，获取用户个数
        count = User.objects.filter(username=username)

        # 组织数据
        context = {
            'count':count,
            'uername':username
        }

        return Response(context)
